﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_Flow_DeleteJump]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_Flow_DeleteJump];
GO
CREATE PROCEDURE [dbo].[sproc_Flow_DeleteJump]
    @FlowID int,
    @StepID int,
    @Priority int
AS
    DELETE 
        FROM
            uds_flow_jump
        WHERE
            flow_id = @flowid
            and step_id = @stepid
            and priority = @priority
    UPDATE     uds_flow_jump
        SET priority= priority-1
        WHERE     flow_id = @flowid
            and step_id = @stepid
            and priority > @priority

    RETURN 0